package cn.edu.zafu.bigdata.Yum;

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class Client {
    private static final String HOST = "192.168.16.36"; // 服务端主机地址
    private static final int PORT = 1234; // 服务端端口
    public static void main(String[] args) {
        try (Socket socket = new Socket(HOST, PORT);
             PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
             BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
             Scanner scanner = new Scanner(System.in)) {
            System.out.println("Connected to server");
            String userInput;
            while (!(userInput = scanner.nextLine()).equals("bye")) {
                out.println(userInput);
                System.out.println("Server response: " + in.readLine());
            }
            scanner.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}